﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
using UCL.Powersource.Analysis;
using UCL.Powersource.TFS;

namespace UCL.Powersource.Mock
{
    [DataContract]
    [KnownType(typeof(DummyAnalysisBridge))]
    [KnownType(typeof(DummyTeamProjectCollectionConfiguration))]
    [KnownType(typeof(DummyTeamProjectConfiguration))]
    [KnownType(typeof(DummyTimeframe))]
    [KnownType(typeof(StatisticCollectionWithResults))]

    public class DummyPackageConfiguration : IPackageConfiguration
    {
        public DummyPackageConfiguration()
        {
            _TFSTeamCollectionConfigurations = new List<DummyTeamProjectCollectionConfiguration>();
        }

        public void MergeWithCollection(ITfsTeamProjectCollection collection)
        {
            var tcc = new DummyTeamProjectCollectionConfiguration();
            tcc.TfsTeamProjectCollection = collection;
            tcc.IldasmPath = DefaultIldasmPath;
            tcc.LocalDropBasePath = DefaultLocalDropBasePath;
            tcc.CodeIndexDBServer = DefaultCodeIndexDBServer;
            tcc.ExportPath = DefaultExportPath;
            _TFSTeamCollectionConfigurations.Add(tcc);
        }

        [DataMember]
        private List<DummyTeamProjectCollectionConfiguration> _TFSTeamCollectionConfigurations;

        public IReadOnlyList<ITfsTeamProjectCollectionConfiguration> TFSTeamCollectionConfigurations
        {
            get { return _TFSTeamCollectionConfigurations; }
            //private set { _TFSTeamCollectionConfigurations = (IReadOnlyList<TfsTeamProjectCollectionConfiguration>)value; }
        }

        [DataMember]
        private StatisticCollectionWithResults _TeamProjectCollectionStatistics;

        public IStatisticCollectionWithResults TeamProjectCollectionStatistics
        {
            get { return _TeamProjectCollectionStatistics ?? (_TeamProjectCollectionStatistics = new StatisticCollectionWithResults()); }

        }


        public string DefaultIldasmPath
        {
            get { return "DummyIldasmPath"; }
        }

        public string DefaultLocalDropBasePath
        {
            get { return "DummyDropPath"; }
        }

        public string DefaultCodeIndexDBServer
        {
            get { return "DummyDBServer"; }
        }


        public string DefaultExportPath
        {
            get { return "DummyExport"; }
        }


        public string CreateDefaultWebServiceUrl(string collectionUrl)
        {
            return collectionUrl;
        }
    }

    public class DummyPackageConfigurationFactory : IPackageConfigurationFactory
    {
        public IPackageConfiguration Create()
        {
            return new DummyPackageConfiguration();
        }
    }

}
